<template>
	<view>
    <view class="info" v-if="nowPage == 0">
      <repair></repair>
    </view>
    <view class="info" v-if="nowPage == 1">
      <truck></truck>
    </view>
    <view class="info" v-if="nowPage == 2">
      <mid @submitSuccess="submitSuccess" :add="add" @loginSuccess="loginSuccess"></mid>
    </view>
    <view class="info" v-if="nowPage == 3">
      <parts></parts>
    </view>
    <view class="info" v-if="nowPage == 4">
      <my :user="user" @toLogin="nowPage = 2"></my>
    </view>
    <main-foot :page="nowPage" @nav="goNav"></main-foot>
	</view>
</template>

<script>
  import mainFoot from '@/components/foot'
  import truck from '@/pages/truck/truck'
  import repair from '@/pages/repair/repair'
  import mid from '@/pages/mid/mid'
  import parts from '@/pages/parts/parts'
  import my from '@/pages/my/my'
	export default {
		data() {
			return {
        nowPage:0,
        add:-1,
        user:{}
			}
		},
		onLoad(option) {
      if(option.page != null) {
        this.nowPage = option.page;
      }
      console.log(option)
		},
		methods: {
      
      goNav:function(index,mid){
        this.nowPage = index;
        this.add = mid;
        
        if(index != 2) {
          this.add = -1;
        }
        // console.log(this.add)
        // console.log(this.nowPage)
      },
      loginSuccess:function(user) {
        this.nowPage = 4;
      },
      submitSuccess:function(key) {
        this.goNav(key);
      }
		},
    components:{
      mainFoot,
      truck,
      repair,
      mid,
      parts,
      my
    }
	}
</script>

<style>
  * {
    margin: 0;
    padding: 0;
  }
  .info {
    height: 1336rpx;
  }
/*  .mybtn {
    width: 600rpx;
    height: 100rpx;
    line-height: 100rpx;
  } */
</style>
